import { BaseViewModel, BasePageInfo } from '@ohos/lib_common'
import { API } from '../../../common/constants/api'

// 文章分类
export interface ArticleCategoryItem {
  articleCategoryId?: string
  name?: string
  status?: number
  createBy?: number
  createDate?: string
  updateBy?: string
  updateDate?: string
  delFlag?: boolean
  orderNum?: number
}

// 文章信息 item
export interface ArticleItem {
  "articleId": string
  "origin": string
  "title": string
  "introduce": string
  "content": string
  "endTime": string
  "startTime": string
  "keyword": string
  "url": string
  "articleCategorycategoryId": string
  "articleCategoryName": string
  "mediaUrl": string
  "type": number
  "writer": number
  "orginUrl": string
  "coverUrl": string
  "baseClick": number
  "baseShare": number
  "baseComment": number
  "realClick": number
  "realShare": number
  "realComment": number
  "realGoodClick": number
  "hotReply": string
  "hotReplyId": string
  "issueBy": string
  "status": number
  "mediaTitle": string
  "mediaCover": string
  "blockComments": number
  "homePage": number
  "push": number
  "share": number
  "publishDate": string
  "createBy": string
  "createDate": string
  "updateBy": number
  "updateDate": string
  "orderNum": number
  "delFlag": boolean,
  "preUrl": string
  "programResourceId": number
  "articleStatus": number
}

// 路况信息数据
interface ArticleData extends BasePageInfo {
  records: ArticleItem[]
}

// 查询列表传参
export interface SearchListParams {
  articleCategoryId: string
  current: number
  size: number
  pushFlag: boolean
}

export class ArticleModal extends BaseViewModel {
  // 获取文章分类
  async getArticleCategory() {
    const res = await this.get<ArticleCategoryItem[]>({ url: API.ARTICLE_CATEGORY })
    return res
  }
  // 获取文章列表
  async getArticleList(data: SearchListParams) {
    const res = await this.get<ArticleData>({ url: API.ARTICLE_DATA, data })
    return res
  }
}

export const articleModal = new ArticleModal()